<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/page/public/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>客户资源</title>
<% request.setAttribute("menu", 1); %>
<%@ include file="/WEB-INF/page/public/contentmeta.jsp"%>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="<%=basePath%>css/global.css" media="all" />
<link rel="stylesheet" href="<%=basePath%>plugins/font-awesome/css/font-awesome.min.css"/>
<link rel="stylesheet" href="<%=basePath%>css/system.css" media="all"/>
<link rel="stylesheet" href="<%=basePath%>css/tab.css" media="all" />
    
</head>
<body>


<div class="admin-tab admin-user admin-transform">

	<div class="tab-condition">
        <form class="layui-form clefix" id="htform" action="/customer/customerstatistics" method="post">
            <div class="layui-form-item">
                <div class="layui-input-inline">
                    <select name="uid" >
                    		<option value="-1">请选择用户</option>
                    	<c:forEach var="nameobj" items="${userlist}">
                    		<option value="${nameobj.uid}" <c:if test="${ nameobj.uid == uid }">selected</c:if> >${nameobj.name}</option>
                    	</c:forEach>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
	            <input name="skipToPage" id="skipToPage"  type="hidden" value="${pager.pageNo}">
				<input type="hidden" id="pageNo" name="pageNo" value="${pager.pageNo}">
				<input type="hidden" id="totalPage" name="totalPage" value="${pager.totalPages}">
				<input type="hidden" id="approvalstatushide" value="${pager.params.approvalstatus}">
				<input type="hidden" id="stateshide" value="${pager.params.state}">
                <button class="layui-btn TM-btn-search searchbtn" lay-submit="" lay-filter="demo2"><i class="layui-icon layui-unselect layui-tab-close">&#xe615;</i>搜索</button>
               <button class="layui-btn refreshbtn"  type="button"><i class="layui-icon layui-unselect layui-tab-close ">&#x1002;</i>刷新</button>  
            </div>
        </form>
    </div>
    
    <div class="layui-field-box">
        <table class="site-table table-hover TM-user">
            <thead>
	            <tr>
	                <th style="width:200px;">姓名</th>
	                <th style="width:150px;">现有企业资源</th>
	                <th style="width:170px;">企业资源限制</th>
	                <th style="width:170px;">现有人才资源</th>
	                <th style="width:225px;">人才资源限制</th>
	                <th style="width:105px;">今日录入企业</th>
	                  <th style="width:105px;">今日录入人员</th>
	                <th style="width:165px;">操作</th>
	            </tr>
            </thead>
            <tbody>
            	<c:if test="${uid == null || uid == -1}">
            		<c:forEach var="obj" items="${userlist}" varStatus="o1">
	           			<tr data="${obj.uid}">
		           			<td>${obj.name}</td>
			                <td>${obj.nowcustom}</td>
			                <td>${obj.maxcustom}</td>
			                <td>${obj.nowresume}</td>
			                <td>${obj.maxresume}</td>
			                 <td>${obj.currentEcount}</td>
			                 <td>${obj.currentPcount}</td>
			                <td>
			                	<a href="#" class="layui-btn layui-btn-normal layui-btn-mini updaterestrict" mc="${obj.maxcustom}" mr="${obj.maxresume}">更改限制</a>
			                </td>
	           			</tr>
           			</c:forEach>
            	</c:if>
            	<c:if test="${uid != null && uid > 0 }">
            		<tr data="${uif.uid}">
	           			<td>${uif.name}</td>
		                <td>${uif.nowcustom}</td>
		                <td>${uif.maxcustom}</td>
		                <td>${uif.nowresume}</td>
		                <td>${uif.maxresume}</td>
		                <td>
		                	<a href="#" class="layui-btn layui-btn-normal layui-btn-mini updaterestrict" mc="${uif.maxcustom}" mr="${uif.maxresume}">更改限制</a>
		                </td>
	           		</tr>
            	</c:if>
           		
            </tbody>
        </table>
    </div>
    
    
    <!-- 修改限制弹窗 -->
    <div class="changerestrict" style="display: none;">
   		<form action="" method="post" id="changerestrictform">
   			<div style="padding-top: 10%;">
		   		<div class="layui-form-item">
		           	<label class="layui-form-label"><span>企业资源:</span></label>
		               <div class="layui-input-inline">
		               	<input type="text" name="maxcustom" class="layui-input maxcustomcount">
		               </div>
		   		</div>
		   		<div class="layui-form-item">
		           	<label class="layui-form-label"><span>个人资源:</span></label>
		               <div class="layui-input-inline">
		               	<input type="text" name="maxresume" class="layui-input maxresumecount">
		               </div>
		   		</div>   				
   			</div>

   		</form>
    </div>
    
    
</div>
    
    <script>

	layui.use(['icheck','element','laypage','form','laydate'],function(){
		
		var $ = layui.jquery,
        layer = layui.layer,
        laypage = layui.laypage;
        var form = layui.form();
        //var pageNo = $("#pageNo").val();
    	//var totalPage = $("#totalPage").val();
		/* //分页按钮
    	laypage({
            cont: 'page',
            curr: pageNo//'${pager.pageNo}'
            ,pages: totalPage//'${pager.totalPages}' //总页数
            ,
            groups: 5 //连续显示分页数
            ,
            skip: true,
            jump: function(obj, first) {
                //得到了当前页，用于向服务端请求对应数据
                var curr = obj.curr;
                if(!first) {
                	$("#skipToPage").val(curr);
                	$("#transformform").submit();
                }
            }
        });  */
		
        
        
        
        
		//更改企业限制
		$(document).on("click",".updaterestrict",function(){
			
			var uid = $(this).parent().parent().attr("data");
			var maxcustom = $(this).attr("mc");
			var maxresume = $(this).attr("mr");
			$(".maxcustomcount").val(maxcustom);
			$(".maxresumecount").val(maxresume);
			
			layer.open({
        		type:1,
	   		  	btn:['确定','取消'],
	           	btnAlign:'c',
	           	shadeClose:true,
		  		title:"更改资源数",
		  		zIndex: 999,
		  		content: $(".changerestrict"),
		  		area:['40%','50%'],
		  		maxWidth:800,
		  		yes: function(layero, index){
		  			var maxcustomcount = $(".maxcustomcount").val();
		  			var maxresumecount = $(".maxresumecount").val();
					layer.closeAll();
		  			$.ajax({
						type : "post",
						data : {uid:uid,maxcustomcount:maxcustomcount,maxresumecount:maxresumecount},
						url : "/customer/changeresourcerestrict",
						dataType : "json",
						success : function(data){
							if (data == 0) {
								layer.msg("修改限制失败,请重试",{icon: 5,time: 700},function(){
									window.location.reload();
								});
							} else if (data == -1) {
								layer.msg("参数输入不合法,请输入一个数字",{icon: 5,time: 700},function(){
									window.location.reload();
								});
							} else {
								layer.msg("修改限制成功",{icon: 1,time: 700},function(){
									window.location.reload();
								});
							}					
						}
		  			});
		  		}
			});
			
			
			
			
			
			
			
			/* var type = $(this).attr("data");
			
			var title = "";
			var count = 300;
			if (type == 1) {
				title = "请输入企业最大资源数";
			} else {
				title = "请输入人才最大资源数";
			} 
			layer.prompt({title:title,formType:3},function(text, index){
				count = text;
				layer.close(index);
				$.ajax({
					type : "post",
					url : "/customer/changeresourcerestrict",
					data : {type:type,uid:uid,count:count},
					dataType : "json",
					success : function(data){
						if (data == 0) {
							layer.msg("修改限制失败,请重试",{icon: 5,time: 700},function(){
								window.location.reload();
							});
						} else if (data == -1) {
							layer.msg("参数输入不合法,请输入一个数字",{icon: 5,time: 700},function(){
								window.location.reload();
							});
						} else {
							layer.msg("修改限制成功",{icon: 1,time: 700},function(){
								window.location.reload();
							});
						}
					}
				});
			}); */
		});
		
		
		
		
		
        
	});

	</script>

</body>
</html>